package com.chief.hadoop.mr.combiner;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class FlowMapper extends Mapper<LongWritable, Text, FlowBean, NullWritable> {

    FlowBean flowBean = new FlowBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        String line = value.toString();
        String[] split = line.split("\t");
        flowBean.setPhone(split[1]);
        flowBean.setTotal(Long.valueOf(split[split.length - 2]) + Long.valueOf(split[split.length - 3]));
        context.write(flowBean, NullWritable.get());
    }
}
